namespace Radar.Test
{
    using Moq;
    using NUnit.Framework;

    [TestFixture]
    public class ContainerExtensionsTest
    {
        public abstract class A
        {
        }

        public class B : A
        {
        }

        private Mock<IContainer> containerMock;
        private IContainer container;

        [SetUp]
        public void SetUp()
        {
            containerMock = new Mock<IContainer>();
            container = containerMock.Object;
        }

        [Test]
        public void WillRegisterClasses()
        {
            container.RegisterAllFrom(typeof(ContainerExtensionsTest).Assembly, (x, y) => typeof(A) == x);

            containerMock.Verify(x => x.Register(typeof(A), typeof(B)), Times.Once());
        }

        [Test]
        public void WillRegisterAllFromAssembly()
        {
            container.RegisterAllFrom(typeof(A).Assembly);

            containerMock.Verify(x => x.Register(typeof(A), typeof(B)), Times.Once());
        }

        [Test]
        public void WillRegisterWithoutBaseTypeFrom()
        {
            container.RegisterSingleFrom(typeof(B).Assembly, (x, y) => x == typeof(B));

            containerMock.Verify(x => x.Register(typeof(B), typeof(B)), Times.Once());
        }
    }
}